import pymysql
import os
from configparser import  ConfigParser
path = os.getcwd()
cfg = ConfigParser()

cfg.read(path + os.sep + "config.ini")
host=cfg.get("global","db_host")
user=cfg.get("global","db_user")
password=cfg.get("global","db_password")
db_bg=cfg.get("global","db_bg")
db_bg_mg=cfg.get("global","db_bg_mg")


class DBUtils:
    gy_con = pymysql.connect(host=host,user=user,password=password,database=db_bg)
    gy_mg_con = pymysql.connect(host=host,user=user,password=password,database=db_bg_mg)

    #专门处理增，删，改
    def update(self,sql,con,param):
        cursor = con.cursor()
        cursor.execute(sql, param)
        con.commit()


    # 专门处理查询接口
    def select(self,sql,con,param):
        cursor = con.cursor()
        cursor.execute(sql, param)
        con.commit()


        return cursor.fetchall()

    def release(self,con):
        con.close()
















